import { debounce } from "lodash-es";

export default function useInput(key: string) {
  const iptEl = useTemplateRef<HTMLInputElement>(key);
  const setIptVal = debounce(function (): void {
    const el = unref(iptEl);
    if (el) {
      console.log(el.value);
    } else {
      console.warn("Input element is not available.");
    }
  }, 300);

  return {
    setIptVal,
  };
}
